package edu.colorado.karl.intelsched;

import java.util.ArrayList;

import edu.colorado.karl.databases.*;

/**
 * Assembles information for the Intelligent Scheduler
 */
public class ISInfoBuilder {
	//	Don't initialize this class, no need.
	private ISInfoBuilder() {
		
	}
	
	/**
	 * Creates an ISInfo from the current databases.
	 * @return An ISInfo with current sensor and set point values.
	 */
	static public ISInfo buildISInfo()
	{
		ISInfo isi = null;
		LongTermDatabase ltd = new LongTermDatabase();
		SetpointsDatabase spd = new SetpointsDatabase();
		
		ArrayList<SPResponse> spl = spd.getRoomSetPoints();
		int roomSet=0;
		int roomRange=0;
		
		for (SPResponse val : spl) {
			if(val.getName().equals(SetpointsDatabase.ROOM_TEMP))
				roomSet = val.getValue();
			else if(val.getName().equals(SetpointsDatabase.ROOM_RANGE))
				roomRange = val.getValue();
			
		}
		isi = new ISInfo((double)roomSet, (double)roomRange,
				ltd.getSolarPanelTemperature().get(0).getValue());
		return isi;
	}
}
